package com.itany.corejava.day02;

import java.math.BigDecimal;

public class Test2 {

    public static void main(String[] args) {


        /*
            java内部没有byte,short
            当作int类处理
            为了c++程序员方便
            用byte,short不能提高性能
            也不能节省空间
         */
        byte b1=1;//int->byte

        byte b2= (byte) (b1+b1);//强制类型转换 int->byte

        byte b3=1+1;//jdk会做优化，编译是做的计算 byte b3=2;

        int i1=128;
        
        byte b4= (byte) i1;

        System.out.println("b4 = " + b4);
    



        int i=2100000000;

        int max=0x7fffffff;
        int min=0x80000000;

        System.out.println("min = " + min);
        System.out.println("max = " + max);
        
        int i2=010;
        System.out.println("i2 = " + i2);


//        long l1=1024*1024*1024*2;//自动类型转换 int->long
        long l1=1024L*1024*1024*2;
        System.out.println("l1 = " + l1);


        double d=1;//int->double
        System.out.println("d = " + d);

        double d2=2.3;
        int i3= (int) d2;//小数取整操作
        System.out.println("i3 = " + i3);

        float f= (float) 1.2;

        System.out.println("f = " + f);
        
        float f2=1.2F;

        System.out.println("f2 = " + f2);

        //double存储不精确
        System.out.println("12.345-12 = " + (12.345 - 12));
        System.out.println("2.6-2 = " + (2.6-2));

        BigDecimal bd1=new BigDecimal("12.345");
        BigDecimal bd2=new BigDecimal("12");
        System.out.println(bd1.subtract(bd2));


        double d1=5/2;
        System.out.println("d1 = " + d1);

        double d3=5.0/2;
        System.out.println("d3 = " + d3);


        char c='a';

        System.out.println("c = " + c);

        //java内部char当作int来处理
        char c1=78;

        System.out.println("c1 = " + c1);
        System.out.println("c+1 = " + (c+1));

        int i4='b';
        System.out.println("i4 = " + i4);

        double num=Math.random();//[0,1)

        System.out.println("num = " + num);

        //随机生成一个a-z之间的字符
        char c2= (char) (((int)(Math.random()*('z'-'a'+1)))+'a');

        System.out.println("c2 = " + c2);

        //将‘5’转换成5
        char c3='5';
        //错
//        int i5=c3;
        int i5=c3-'0';

        System.out.println("i5 = " + i5);

        char c4='中';

        System.out.println("c4 = " + c4);

        char c5='\u4e2d';

        System.out.println("c5 = " + c5);
        
        boolean bool1=true;
        boolean bool2=false;

        boolean bool3=1>3;

        System.out.println("bool1 = " + bool1);
        System.out.println("bool2 = " + bool2);
        System.out.println("bool3 = " + bool3);








    }
}
